<template>
  <div class="dashboard-container">
    <!--<div class="dashboard-text">name:{{ name }}</div>-->
    <!--<div class="dashboard-text">roles:<span v-for="role in roles" :key="role">{{ role }}</span></div>-->
  </div>
</template>

<script>
// import { mapGetters } from 'vuex';
// import { isMediumUser, isBrandUser, isCRMNormal, hasRouteAuth, ROUTER_TYPES } from '@/utils/permission';

/**
 * 中间页
 */
export default {
  name: 'Index',
  // computed: {
  //   ...mapGetters([
  //     'name',
  //     'roles'
  //   ])
  // },
  created() {
    this.$router.replace({ name: 'Index' });
    // if (isCRMNormal() && hasRouteAuth([ROUTER_TYPES.CRM_ORDER])) {
    //   this.$router.replace({ name: 'allOrder' });
    // } else if (isBrandUser() && hasRouteAuth([ROUTER_TYPES.BRAND])) {
    //   this.$router.replace({ name: 'fileList' });
    // } else if (isMediumUser() && hasRouteAuth([ROUTER_TYPES.MEDIUM])) {
    //   this.$router.replace({ name: 'medium' });
    // } else {
    //   this.$router.replace({ name: 'Index' });
    // }
  },
  beforeRouteEnter(to, from, next) {
    const query = new URLSearchParams(location.search || '?');
    let redirect = query.get('redirect');
    const isFeishu = query.get('isFeishu');
    const obj = {};
    if (isFeishu) obj.isFeishu = isFeishu;
    if (redirect && redirect !== '' && redirect !== 'null') {
      for (const [key, value] of query.entries()) {
        if (key !== 'redirect' && value) {
          redirect += `${redirect.indexOf('?') < 0 ? '?' : '&'}${key}=${value}`;
        }
      }
      obj.path = decodeURIComponent(redirect);
      next(obj);
    } else {
      next(obj);
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
